package com.cnhis.cloudhealth.clidoctorweb.patientcase;

import javax.ws.rs.FormParam;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.logging.Logger;
import org.springframework.stereotype.Component;

import com.alibaba.dubbo.config.annotation.Reference;
import com.cnhis.cloudhealth.clinical.clidoctor.patientcase.service.IPatientCase;
import com.cnhis.cloudhealth.commons.Mappers.ModelVo;
import java.util.HashMap;

@Path("patientcase")
@Component
public class PatientCaseRest {
	Logger log = Logger.getLogger(PatientCaseRest.class); 

	@Reference
	private IPatientCase patientCase;
	/* ScriptId(1719) */
	/* Description(EMR_病历提醒) */
	/**
	 * 
	 * @param BCE01 员工id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("patientcasereminder")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo patientCaseReminder(@FormParam("BCE01") int BCE01,
			@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("BCE01", BCE01);
		return patientCase.patientCaseReminder(hs, (currPage-1)*pageSize, pageSize);
	}
	/* ScriptId(7129) */
	/* Description(病人病历列表) */
	/**
	 * 
	 * @param VAA01 病人id
	 * @param VAA07 就诊id
	 * @param ACF01 医疗服务 病人来源
	 * @param VAP01 婴儿id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("patientcaselist")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo patientCaseList(@FormParam("VAA01") int VAA01,
			@FormParam("VAA07") int VAA07,
			@FormParam("ACF01") int ACF01,
			@FormParam("VAP01") int VAP01,
			@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("VAA01", VAA01);
		hs.put("VAA07", VAA07);
		hs.put("ACF01", ACF01);
		hs.put("VAP01", VAP01);
		return patientCase.patientCaseList(hs, (currPage-1)*pageSize, pageSize);
	}
	/* ScriptId(7128) */
	/* Description(病人可用病历,包括病历文件，范文文件) */
	/**
	 * 
	 * @param Type 类型
	 * @param VAA01 病人id
	 * @param VAA07 病人登记id
	 * @param ACF01
	 * @param VAP01
	 * @param AAG01
	 * @param BCK01 科室id
	 * @param EmpId 人员id
	 * @param DeptId 住院科室id
	 * @param DocumentId
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("patientefficaciouscase")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo patientEfficaciousCase(@FormParam("Type") int Type,@FormParam("VAA01") int VAA01,
			@FormParam("VAA07") int VAA07,
			@FormParam("ACF01") int ACF01,
			@FormParam("VAP01") int VAP01,
			@FormParam("AAG01") String AAG01,
			@FormParam("BCK01") int BCK01,
			@FormParam("EmpId") int EmpId,
			@FormParam("DeptId") int DeptId,
			@FormParam("DocumentId") int DocumentId,@FormParam("currPage") int currPage,@FormParam("pageSize") int pageSize
			)throws Exception{
		HashMap hs = new HashMap();
		hs.put("Type", Type);
		hs.put("VAA01", VAA01);
		hs.put("VAA07", VAA07);
		hs.put("ACF01", ACF01);
		hs.put("VAP01", VAP01);
		hs.put("AAG01", AAG01);
		hs.put("BCK01", BCK01);
		hs.put("EmpId", EmpId);
		hs.put("DeptId", BCK01);
		hs.put("DocumentId", DocumentId);
		return patientCase.patientEfficaciousCase(hs, currPage, pageSize);
	}
	/* ScriptId(7304) */
	/* Description(临床医护查看检验报告) */
	/**
	 * 
	 * @param ACF01
	 * @param LAB09 病历号
	 * @param VAA03
	 * @return
	 * @throws Exception
	 */
	
	@SuppressWarnings("unchecked")
	@POST
	@Path("viewinspectionreport")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo viewInspectionReport(@FormParam("ACF01") int ACF01,@FormParam("LAB09") String LAB09,@FormParam("VAA03") String VAA03,@FormParam("currPage") int currPage,@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("LAB09", LAB09);
		hs.put("ACF01", ACF01);
		hs.put("VAA03", VAA03);
		
		return patientCase.viewInspectionReport(hs, currPage, pageSize);
	}
	/* ScriptId(4236) */
	/* Description(检验_查找默认仪器) */
	@POST
	@Path("finddefaultinstrumentequipment")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo findDefaultInstrumentEquipment()throws Exception{
		return patientCase.findDefaultInstrumentEquipment();
	}
	/* ScriptId(7305) */
	/* Description(临床医护查看检验报告，常规检验结果) */
	/**
	 * 
	 * @param LAB01 检验标本id
	 * @param currPage
	 * @param pageSize
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("conventionresult")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo conventionResult(@FormParam("LAB01") int LAB01,
			@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("LAB01", LAB01);
		return patientCase.conventionResult(hs, currPage, pageSize);
	}
	/* ScriptId(7306) */
	/* Description(检验报告对应图像) */
	/**
	 * 
	 * @param LAB01 标本id
	 * @param BEY01 仪器id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("inspectionreportimage")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo inspectionReportImage(@FormParam("LAB01") int LAB01,@FormParam("BEY01") int BEY01,@FormParam("currPage") int currPage,@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("LAB01", LAB01);
		hs.put("BEY01", BEY01);
		return patientCase.inspectionReportImage(hs, (currPage-1)*pageSize, pageSize);
	}
	/* ScriptId(7251) */
	/* Description(医师站查看检验报告结果) */
	/**
	 * 
	 * @param ACF01
	 * @param LAB09 病历号
	 * @param VAA03
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("doctorconventionresult")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo doctorConventionResult(@FormParam("ACF01") int ACF01,@FormParam("LAB09") String LAB09,@FormParam("VAA03")  String VAA03,@FormParam("currPage") int currPage,@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("ACF01", ACF01);
		hs.put("LAB09", LAB09);
		hs.put("VAA03", VAA03);
		return patientCase.doctorConventionResult(hs, currPage, pageSize);
	}
	/* ScriptId(7301) */
	
	/* Description(医师浏览影像检查报告结果) */
	/**
	 * 
	 * @param fuser
	 * @param fpass
	 * @param fhost
	 * @param fport
	 * @param VAA01 病人id
	 * @param VAA07
	 * @param ACF01
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("doctorviewimageresult")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo doctorViewImageResult(@FormParam("fuser") String fuser,
			@FormParam("fpass") String fpass,
			@FormParam("fhost") String fhost,
			@FormParam("fport") String fport,
			@FormParam("VAA01") long VAA01,
			@FormParam("VAA07") long VAA07,
			@FormParam("ACF01") int ACF01,
			@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize)throws Exception{
		HashMap hs = new HashMap();
		hs.put("fuser", fuser);
		hs.put("fpass", fpass);
		hs.put("fhost", fhost);
		hs.put("fport", fport);
		hs.put("VAA01", VAA01);
		hs.put("VAA07", VAA07);
		hs.put("ACF01", ACF01);
		return patientCase.doctorViewImageResult(hs, currPage, pageSize);
	}
	
	/* ScriptId(6434) */
	/* Description(提取最后一次病史记录) */
	/**
	 * 
	 * @param aACF01 业务分类
	 * @param aVAA07 就诊id
	 * @param aVAA01 病人id
	 * @param BLP02 42
	 * @param adate 日期
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("getlasthistory")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo getLastHistory(
			@FormParam("aVAA07") long aVAA07,
			@FormParam("type") int type,
			@FormParam("aVAA01") long aVAA01
			)throws Exception{
		HashMap hs = new HashMap();
		hs.put("aACF01", 1);
		hs.put("aVAA07", aVAA07);
		hs.put("aVAA01", aVAA01);
		hs.put("type", type);
		hs.put("mzBLP42", 0);
		return patientCase.getLastHistory(hs);
	}
	/* ScriptId(864) */
	/* Description(检索对应门诊病人 病历记录) */
	/**
	 * 
	 * @param VAA07  就诊id
	 * @param ACF01 病人来源
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("patientcasehistory")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo patientCaseHistory(@FormParam("VAA07") int VAA07,
			@FormParam("ACF01") int ACF01,
			@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize
			)throws Exception{
		HashMap hs = new HashMap();
		hs.put("ACF01", ACF01);
		hs.put("VAA07", VAA07);
		return patientCase.patientCaseHistory(hs, (currPage-1)*pageSize, pageSize);
		
	}
	/* ScriptId(7140) */
	/* Description(查询病人单个病历) */
	/**
	 * 
	 * @param VAQ01 病历id
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("getpatinetcase")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo getPatinetCase(@FormParam("VAQ01") int VAQ01)throws Exception{
		HashMap map = new HashMap();
		map.put("VAQ01", VAQ01);
		return patientCase.getPatinetCase(map);
	}
	/* ScriptId(6435) */
	/* Description(提取检查病历摘要) */
	@SuppressWarnings("unchecked")
	@POST
	@Path("fetchpatientsummary")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo fetchPatientSummary(@FormParam("cbm01") int cbm01,
			@FormParam("acf01") int acf01)throws Exception{
		HashMap map = new HashMap();
		map.put("cbm01", cbm01);
		map.put("acf01", acf01);
		return patientCase.fetchPatientSummary(map);
	}
	//EMR_VAQ1_Update
	//保存病历
	/**
	 * 
	 * @param XML 病历信息
	 * @param VAQ01 病历id
	 * @param State   0: 默认
					  1: 增加病历记录的同时，增加合并病历记录	
					  2: 修改病历
					  3: 审阅病历
					  4: 归档
					  5: 取消归档
					  6: 开始评分
					  7: 取消评分
	 * @param Ver --版本号
	 * @param VAQ01A --VAQ01A 合并病历ID
	 * @param DocText --文本附件内容
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("emrvaq1update")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo emrVAQ1Update(
			@FormParam("XML") String XML,
			@FormParam("VAQ01") long VAQ01,
			@FormParam("State") int State,
			@FormParam("Ver") String Ver,
			@FormParam("VAQ01A") long VAQ01A,
			@FormParam("DocText") String DocText
			)throws Exception{
		HashMap map = new HashMap();
		map.put("XML", XML);
		map.put("VAQ01", VAQ01);
		map.put("State", State);
		map.put("Ver", Ver);
		map.put("VAQ01A", VAQ01A);
		map.put("DocText", DocText);
		return patientCase.emrVAQ1Update(map);
	}
	/* ScriptId(7168) */
	/* Description(查询修改历史) */
	/**
	 * 
	 * @param lVAQ01 病历id
	 * @param currPage
	 * @param pageSize
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@GET
	@Path("findhistory")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo findHistory(@QueryParam("lVAQ01") long lVAQ01
			,@FormParam("currPage") int currPage,
			@FormParam("pageSize") int pageSize
			)throws Exception{
		HashMap map = new HashMap();
		map.put("lVAQ01", lVAQ01);
		return patientCase.findHistory(map, (currPage-1)*currPage, pageSize);
	}
	//EMR_VAQ1_VAQ32_Update
	//变更书写时限
	/**
	 * 
	 * @param xml 修改人  修改时间
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@GET
	@Path("emrvaq1vaq32update")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo emrVaq1Vaq32Update(@FormParam("xml") String xml)throws Exception{
		HashMap map = new HashMap();
		map.put("xml", xml);
		return patientCase.emrVaq1Vaq32Update(map);
	}
	//EMR_VCU1_Update
	//修改病历标记内容
	/**
	 * 
	 * @param VAQ01 病历id
	 * @param XML 病历段落内容
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	@POST
	@Path("emrvcu1update")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo emrVcu1Update(
			@FormParam("VAQ01") long VAQ01,
			@FormParam("XML") String XML
			)throws Exception{
		HashMap map = new HashMap();
		map.put("XML", XML);
		map.put("VAQ01", VAQ01);
		return patientCase.emrVcu1Update(map);
	}
	//QC_QAD1_init
	//添加质控记录
	@SuppressWarnings("unchecked")
	@POST
	@Path("qcqad1init")
	@Produces({ MediaType.APPLICATION_JSON })
	public ModelVo qcQad1init(
			@FormParam("VAQ01") long VAQ01,
			@FormParam("VAA01") long VAA01,
			@FormParam("ACF01") int ACF01
			)throws Exception{
		HashMap map = new HashMap();
		map.put("VAQ01", VAQ01);
		map.put("VAA01", VAA01);
		map.put("ACF01", ACF01);
		return patientCase.qcQad1init(map);
	}
}
